package structure_结构性.composite_pattern_组合模式;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: hihi
 * @Date: 2020/07/07/10:35
 * @Description:
 */
public class User {

	private String name;//姓名
	private String dept;//部门
	private int salary;//薪水
	private List<User> sub;//下级

	public User(String name, String dept, int salary) {
		this.name = name;
		this.dept = dept;
		this.salary = salary;
		this.sub = new ArrayList<>();
	}

	public void add(User user) {
		sub.add(user);
	}

	public void remove(User user) {
		sub.remove(user);
	}

	public List<User> getSub() {
		return sub;
	}

	@Override public String toString() {
		return "User{" +
				"name='" + name + '\'' +
				", dept='" + dept + '\'' +
				", salary=" + salary +
				", sub=" + sub +
				'}';
	}
}
